import {MessagePlugin} from "tdesign-react";


export const copy = (v, message = null) => {
    const oInput = document.createElement('textarea');
    oInput.rows = 10000
    oInput.value = v;
    document.body.appendChild(oInput);

    oInput.style.whiteSpace = 'pre-wrap';
    oInput.select(); // 选择对象
    document.execCommand('Copy'); // 执行浏览器复制命令
    oInput.className = 'oInput';
    oInput.style.display = 'none';
    document.body.removeChild(oInput);
    MessagePlugin.success(message || `已复制：${v}`, 2000).then()

};

